import {customeStruct} from '../utils';
const itf = customeStruct.interface;

const defaultProps = {
    id: 'string',
    code: 'string',
    partSaleOrderId: 'string',
    dealerCode: 'string',
    partOrderTypeName: 'string',
    rowVersion: 'string',
    partSaleOrderStatus: 'number',
};

export const init = itf({
    payload: itf({
        isDealerUser: 'boolean',
        partSaleOrderTypes: [itf({
            id: 'string',
            code: 'string? | null',
            name: 'string? | null',
        })],
        brands: [itf({
            id: 'string',
            code: 'string? | null',
            name: 'string? | null',
        })],
    })
});

export const list = itf({
    payload: itf({
        content: [itf(Object.assign({
            options: ['string']
        }, defaultProps))],
        totalElements: 'number',
    })
});

export const detail = itf({
    payload: itf({
        id: 'string',
        rowVersion: 'string',
        bankAccount: 'string',
        status: 'number',
        attachments: [itf({
            fileId: 'string? | null',
            fileName: 'string? | null',
        })],
        details: [itf({
            id: 'string',
            partId: 'string',
            partCode: 'string',
            partName: 'string',
            newPartId: 'string? | null',
            newPartCode: 'string? | null',
            newPartName: 'string? | null',
            quantity: 'number? | null',
        })],
        operationHistories: [itf({
            id: 'string? | null',
            operatorName: 'string? | null',
            operateStatus: 'string? | null',
        })],
        partSaleOrder: itf({
            id: 'string',
            brandId: 'string',
            brandCode: 'string',
            dealerId: 'string',
            dealerCode: 'string',
        }),
        options: ['string']
    })
});

export const partSaleOrderList = itf({
    payload: itf({
        content: [itf({
            id: 'string',
            code: 'string',
            dealerCode: 'string',
            dealerName: 'string? | null',
            totalQuantity: 'number? | null',
            partOrderTypeName: 'string? | null',
            partOrderPriceTerms: 'number? | null',
            paymentType: 'number? | null',
            status: 'number',
        })]
        
    })
});

export const partSaleOrderDetail = itf({
    payload: itf({
        id: 'string',
        code: 'string',
        dealerCode: 'string',
        dealerName: 'string? | null',
        totalQuantity: 'number? | null',
        partOrderTypeName: 'string? | null',
        partOrderPriceTerms: 'number? | null',
        paymentType: 'number? | null',
        status: 'number',
        details: [
            itf({
                id: 'string',
                partId: 'string',
                partCode: 'string',
                partName: 'string',
                oldPartId: 'string? | null',
                oldPartCode: 'string? | null',
                oldPartName: 'string? | null',
                quantity: 'number? | null',
            })
        ]
    })
});

export const partSalePirce = itf({
    payload: itf({
        partId: 'string',
        partCode: 'string',
        partName: 'string',
        price: 'number? | null',
    })
});

export const dealerSelectList = itf({
    payload: itf({
        content: [itf({
            id: 'string',
            code: 'string',
            name: 'string'
        })],
    })
});

export const bank = itf({
    payload: itf({
        content: [itf({
            id: 'string',
            code: 'string',
            name: 'string',
            account: 'string',
        })],
    })
});

export const HistoryList = itf({
    payload: itf({
        content: [itf({
            id: 'string',
        })],
    })
});

export const HistoryDetail = itf({
    payload: itf({
        id: 'string',
    })
});


